<?php

namespace App\Http\Requests;

use Illuminate\Foundation\Http\FormRequest;

class GoodCateStoreRequest extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        return [
            'name' => ['required', 'max:40', 'unique:good_cates'],
            'sort' => ['required', 'integer'],
        ];
    }
    public function messages()
    {
        return [
            'name.required' => '分类名称不能留空',
            'name.max' => '分类名称不能超过40个字符',
            'name.unique' => '提交的分类名称已存在',
            'sort.required' => '排序不能留空',
            'sort.integer' => '排序必须是正整数',
        ];
    }
}
